<%--
  @desc: 字典系统角色编辑更新
  @author: fym
  @create: 2014-7-22 上午 9:32
--%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style type="text/css">
    .pageFormContent .textInput { width: 220px; }
</style>
<script type="text/javascript">
</script>
<div class="pageContent">
    <form id="pagerForm" method="post" action="<c:url value='/sys/dict/edit'/>" class="pageForm required-validate"
          onsubmit="return validateCallback(this,callbackForSubmit)">
        <div class="pageFormContent">
            <p>
                <label for="txt_dict_title">字典标题</label>
                <input id="txt_dict_title" type="text" name="title" class="required textInput" maxlength="300" value="${dictItem.title}"/>
            </p>
            <p>
                <label for="text_dict_show">字典所属</label>
                <input id="text_dict_show" type="text" readonly=readonly class="required textInput" value="${dictItem.parentName}">
                <input id="text_dict_pid" type="hidden" name="parentId" class="required" maxlength="300" value="${dictItem.parentId}">
            </p>
            <p>
                <label for="txt_dict_val">字典值</label>
                <input id="txt_dict_key" type="hidden" name="key"  value="${dictItem.key}" maxlength="300"/>
                <input id="txt_dict_val" type="text" name="val" class="textInput" maxlength="300" value="${dictItem.val}"/>
            </p>
            <p>
                <label for="txt_dict_remark">备注信息</label>
                <input id="txt_dict_remark" type="text" name="remark" class="textInput" maxlength="300" value="${dictItem.remark}"/>
            </p>
            <p>
                <label for="txt_dict_sort">排序</label>
                <input id="txt_dict_sort" type="text" name="sort" class="required numberbox textInput" maxlength="4" value="${dictItem.sort}"/>
            </p>
            <label>
                <input type="hidden" name="id" value="${dictItem.id}"/>
            </label>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">保存</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script type="text/javascript">
    function callbackForSubmit(resp, st, xhr) {
        if (resp && resp.succ) {
            alertMsg.info("修改成功！");
            changeListAndTree("${dictItem.id}");
        } else {
            alertMsg.info(resp.msg + "!");
        }
    }
    //动态改变树的名字和列表的中的改变
    function changeListAndTree(id) {
        //字典标题
        var title = $("#txt_dict_title").val();
        //刷新列表
        $("#dict_list").loadUrl("<c:url value='/sys/dict/sub/#'/>".replace("#", "${dictItem.parentId}"));
        //获取改变节点
        var changeNode = zTree.getNodesByParam("id", id, null)[0];
        //更改节点名称
        changeNode.name = title;
        //更新节点
        zTree.updateNode(changeNode);
    }
</script>